<?php
/**
 * Created by PhpStorm.
 * User: CYJiao
 * Date: 6/18/15
 * Time: 22:26
 */

?>

<style>
    .table-patient table{border-right:1px dashed #EEEEEE;border-bottom:1px dashed #EEEEEE}
    .table-patient table td{border-left:1px dashed #EEEEEE;border-top:1px dashed #EEEEEE}
    .table-patient table th{border-left:1px dashed #EEEEEE;border-top:1px dashed #EEEEEE}
    input:disabled{
        border: 1px solid #DDD;
        background-color: #FAFAFA;
        color:#000000;
    }
</style>
<script>
      function pk_outpatient_ehr_del(){
        if($('#del_reason').val() == ''){
            alert('废除原因不能为空');
            return false;
        }
        $.ajax({
            type: 'POST',
            url: '<?php echo CController::createUrl('eHR/delPatientEHR') ;?>',
            data: {del_reason:$('#del_reason').val(),pk_outpatient_ehr_id:'<?php echo $ehrInfo->pk_outpatient_ehr_id; ?>'},
            success: function(data){
                if(data.status==0){
                    var maintab = $('#main-tab');
                    alert('废除成功');
                    var tab = maintab.tabs('getSelected');
                    tab.panel('refresh', "<?php echo Yii::app()->request->baseUrl; ?>/index.php?r=eHR/getPatientEHRContent&pk_outpatient_ehr_id=<?php echo $ehrInfo->pk_outpatient_ehr_id;?>");

                    $('#ehr').treegrid('load',{
                     url: "<?php echo CController::createUrl('eHR/getEHRS',array('pk_outpatient_id'=>$ehrInfo->fk_outpatient_id)) ;?>"
                    });
                    $('#win_outpatient_ehr').window('close');
                }else{
                    alert('废除失败,请重试');
                }
            },
            dataType: 'json'
        });
    }
</script>

<div class="easyui-panel" data-options="border:false" style="padding:5px;">
    <?php if($same == 1):?>
    <div class="easyui-panel" data-options="border:false" style="width:100%;height:36px;background:#fafafa;margin-bottom: 10px;padding-top:5px;padding-left: 5px;">

<?php if($ehrInfo->invalid ==1):?>

<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$('#win_outpatient_ehr').window('open');">废除病历</a>

<?php endif?>

<?php if($ehrInfo->invalid ==2):?>

<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',disabled:true">已废除病历</a>

&nbsp;<span>废除原因：<?php echo $ehrInfo->del_reason?></span>

<?php endif?>
        

    </div>
    <div id="win_outpatient_ehr" class="easyui-window" closed="true" style="width:300px;height:180px;">
    <form style="padding:10px 20px 10px 40px;" id="pk_outpatient_ehr_del">
        <p>废除原因: 
        <input type="text" name="del_reason" id='del_reason'>
        <input type="hidden" name="pk_outpatient_ehr_id" value = "<?php echo $ehrInfo->pk_outpatient_ehr_id; ?>"></p>

        <div style="padding:5px;text-align:center;">
            <a href="#" class="easyui-linkbutton" icon="icon-ok" onclick="pk_outpatient_ehr_del();">确定</a>
            <a href="#" class="easyui-linkbutton" icon="icon-cancel" onclick = "javascript:$('#win_outpatient_ehr').window('close')">取消</a>
        </div>
    </form>
    </div>

    <?php endif?>
    <div class="easyui-panel" data-options="border:false" style="width:100%;height:30px;background:#fafafa;margin-bottom: 5px;">
        <div class="easyui-layout" data-options="border:false,fit:true">
            <div data-options="region:'west',border:false" style="width:33%;padding:5px;">创建人姓名：&nbsp;&nbsp;<?php echo $creator_name; ?></div>
            <div data-options="region:'center',border:false" style="padding:5px;">病历编号：&nbsp;&nbsp;<?php echo $ehrInfo->pk_outpatient_ehr_id; ?></div>
            <div data-options="region:'east',border:false" style="width:33%;padding:5px;">创建时间：&nbsp;&nbsp;<?php echo $ehrInfo->ehr_time; ?></div>
        </div>
    </div>
    <form id="form-patient-history-ehr" method="post">
        <div class="easyui-panel" data-options="border:true,title:'患者信息'" style="width:100%;padding:5px;background:#fafafa;margin-bottom: 10px;">
            <div class="table-patient">
            <table style="width:100%;">
                <tbody>
                <tr>
                    <th align="right">真实姓名：</th>
                    <td><?php echo $outpatientInfo['true_name']; ?></td>
                    <th align="right">性别：</th>
                    <td>
                        <?php
                            if($outpatientInfo['gender']==1){
                                echo '男';
                            }else if($outpatientInfo['gender']==2){
                                echo '女';
                            }else {
                                echo '保密';
                            }
                        ?>
                    </td>
                    <th align="right">电话：</th>
                    <td><?php echo $outpatientInfo['phone']; ?></td>
                </tr>
                <tr>
                    <th align="right">生日：</th>
                    <td><?php echo $outpatientInfo['dob']; ?></td>
                    <th align="right">年龄：</th>
                    <td><?php echo age($outpatientInfo['dob']); ?></td>
                    <th align="right">职业：</th>
                    <td><?php echo $ehrInfo['occupation']; ?></td>
                </tr>
                <tr>
                    <th align="right">住址：</th>
                    <td colspan="5"><?php echo $outpatientLocation['address']; ?></td>
                </tr>
                <tr>
                    <th align="right">饮酒：</th>
                    <td>
                        <?php
                            if($ehrInfo['alcohol']==1){
                                echo '从不';
                            }else if($ehrInfo['alcohol']==2){
                                echo '很少';
                            }else if($ehrInfo['alcohol']==3){
                                echo '有时';
                            }else if($ehrInfo['alcohol']==4){
                                echo '经常';
                            }else if($ehrInfo['alcohol']==5){
                                echo '总是';
                            }else {
                                echo '其他';
                            }
                        ?>
                    </td>
                    <th align="right">吸烟：</th>
                    <td>
                        <?php
                        if($ehrInfo['smoke']==NULL){
                            echo '从不';
                        }else{
                            echo $ehrInfo['smoke'].' 支/天';
                        }
                        ?>
                    </td>
                    <th align="right">血型：</th>
                    <td>
                        <?php
                            if($ehrInfo['blood_type']==1){
                                echo 'A';
                            }else if($ehrInfo['blood_type']==2){
                                echo 'B';
                            }else if($ehrInfo['blood_type']==3){
                                echo 'AB';
                            }else if($ehrInfo['blood_type']==4){
                                echo 'O';
                            }else {
                                echo '其他';
                            }
                        ?>
                    </td>
                </tr>
                <tr>
                    <th align="right">体重：</th>
                    <td><?php echo $ehrInfo['weight'].'  kg'; ?></td>
                    <th align="right">身高：</th>
                    <td><?php echo $ehrInfo['stature'].'  cm'; ?></td>
                    <th align="right">民族：</th>
                    <td><?php echo $ehrInfo['nation']; ?></td>
                </tr>
                <tr>
                    <th align="right">过敏史：</th>
                    <td colspan="5"><?php echo $ehrInfo['allergy']?></td>
                </tr>
                </tbody>
            </table>
            </div>
        </div>
        <div id="history-ehr-tab" class="easyui-tabs" data-options="border:true,plain:true" style="height:415px;">
            <div title="病历" data-options="iconCls:'icon-man'" style="padding:5px;">
                <table cellpadding="5" style="width:100%;">
                    <tr>
                        <td style="width:100px;">患者主诉:</td>
                        <td><textarea class="easyui-textbox" type="text" name="outpatient_complaint" id="outpatient_complaint" disabled="disabled" style="width:100%;height:100px;" ><?php echo $ehrInfo['outpatient_complaint']; ?></textarea></td>
                    </tr>
                    <!--<tr style="background-color: #F7F7F7">
                        <td>发病天数:</td>
                        <td><input class="easyui-textbox" type="text" name="disease_days" id="disease_days" disabled="disabled" style="width:50px;" /> 天</td>
                    </tr>
                    -->
                    <tr>
                        <td>现病史:</td>
                        <td><textarea class="easyui-textbox" type="text" name="current_ill" id="current_ill" disabled="disabled" style="width:100%;height:100px;" ><?php echo $ehrInfo['current_ill']; ?></textarea></td>
                    </tr>
                    <tr style="background-color: #F7F7F7">
                        <td>既往病史:</td>
                        <td><textarea class="easyui-textbox" type="text" name="previous_ill_history" id="previous_ill_history" disabled="disabled" style="width:100%;height:100px;" ><?php echo $ehrInfo['previous_ill_history']; ?></textarea></td>
                    </tr>
                </table>
            </div>
        </div>
    </form>
</div>